package cn.wolfcode.controller;

import cn.wolfcode.domain.SysDictType;
import cn.wolfcode.service.ISysDictTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * Created by XuHangBin
 */
@Controller
@RequestMapping("/sysDictType")
public class SysDictTypeController {

    @Autowired
    private ISysDictTypeService sysDictTypeService;



    @RequestMapping("/list")
    public String list(Model model){
        model.addAttribute("sysDictTypeList",sysDictTypeService.selectAll());
        return "sysDictType/view";
    }

    @RequestMapping("/add")
    public String add(){
        return "sysDictType/add";
    }

    @RequestMapping("/saveOrUpdate")
    public String saveOrUpdate(SysDictType sysDictType){
        sysDictTypeService.saveOrUpdate(sysDictType);
        return "redirect:/sysDictType/list";
    }

    @RequestMapping("/edit")
    public String edit(Long id, ModelMap modelMap){
        SysDictType sysDictType = sysDictTypeService.get(id);
        modelMap.put("sysDictType",sysDictType); // 回显
        return "/sysDictType/edit";
    }





}
